<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en" ng-app="regApp">
<head>        
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />    
              
    <title>Forms - Aries Premium Admin Template</title>
    <link rel="stylesheet" type="text/css" href="/Public/css/reg.css">
<link rel="stylesheet" type="text/css" href="/Public/css/index.css"/>
<link rel="stylesheet" type="text/css" href="/Public/css/nav.css"/>
<link rel="stylesheet" type="text/css" href="/Public/css/base.css"/>
<link rel="stylesheet" type="text/css" href="/Public/bootstrap/css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="/Public/Font-Awesome-3.2.1/css/font-awesome.min.css"/>
</head>

<body ng-controller="regForm">  
    <header>
<div class="nav-box">
	<div class="nav-nav">
		<div class="nav-nav-left">
			<a href=""><img class="logo" src="/Public/css/logo.svg" style="height: 47px;line-height: 47px; width: 90px; padding-left: 0.5em;float: left;"></a>
			<a href="" class="item">发现</a>
			<a href="" class="item">帮助</a>
			<a href="" class="item">建议</a>
			<a href="javascript:;" class="finder_box">
					<div class="finder_input">
						<input type="text" class="finder" placeholder="搜索文件"/>	
					</div>
					<div class="finder_btn">
							<i class="icon-search"></i> 
					</div>
			</a>
		</div>
		<div class="nav-nav-right">
			<a href="">
					<img class="logo" src="/Public/css/524316_hlcxxx.png" style="width: 40px;float: right;border-radius: 50%;margin-top:5px;">
			</a>
			<a href="" class="item"><i class="icon-signout"></i></a>
			<a href="" class="item"><i class="icon-envelope"></i></a>
			<a href="" class="item"><i class="icon-user"></i></a>
			<a href="" class="item"><i class="icon-plus"></i></a>
		</div>
	</div>
</div>
</header> 
    <div class="container" style="margin-top:80px">
        <div class="row">
            <div class="col-md-offset-3 col-md-6">
                        
                        <h3 style="color:#F0C040"> <i class="icon-user"></i> &nbsp; 用户注册</h3>

                        <form role="form" ng-submit="submitForm(userForm.$valid)" name="userForm" novalidate="novalidate">

                        <div class="form-group">
                            <label for="username">用户名</label>
                            <input type="text" class="form-control" ng-model="regData.username" name="username" required ng-minlength="3" ng-maxlength="18"/></div>

                        <p ng-show="userForm.username.$error.minlength" class="help-block">Username is too short.</p>

                        <p ng-show="userForm.username.$error.maxlength" class="help-block">Username is too long.</p></span>


                        <div class="form-group">
                                <label for="password">密码</label>
                                <input type="password" class="form-control" ng-model="regData.password" name="password" required   ng-minlength="3" ng-maxlength="18" />
                        </div>

                        
                        <p ng-show="userForm.password.$error.minlength" class="help-block">password is too short.</p>

                        <p ng-show="userForm.password.$error.maxlength" class="help-block">password is too long.</p>

                        <div class="form-group">
                            <label for="repassword">重复密码</label>
                            <input type="password" class="form-control" name="repassword" ng-model="regData.repassword" name="repassword" required  ng-minlength="3" ng-maxlength="18" />
                        </div>
                        
                        <p ng-show="userForm.repassword.$error.minlength" class="help-block">password is too short.</p>
                        <p ng-show="userForm.repassword.$error.maxlength" class="help-block">password is too long.</p>
                        
                        <button class="btn btn-info" type="button" ng-click="gotologin()">Return</button>
                        <button class="btn" type="submit">Submit</button>
                      
                        
                        </form>
            </div> 
        </div>
    </div>
  

</body>
<script src="/Public/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/Public/layer/layer.js" type="text/javascript" charset="utf-8"></script>

<script src="/Public/bootstrap/js/bootstrap.js" type="text/javascript" charset="utf-8"></script>
<script src="/Public/js/angular.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	var app = angular.module('regApp',[]); //声明module
		app.controller('regForm',function($scope,$http){ //声明控制器
			$scope.regData = {};
			  $scope.submitForm = function(isValid) {
		        if (!isValid) {
		            alert('our form is amazing');
		        }else{
		      
			        $http.post('<?php echo U('reg');?>', $scope.regData)
				        .success(function(data) {
				           	console.log(data);
                            if(data){
                                layer.msg("注册成功",function(){
                                       location.href = "/Home/login/login" 

                                });
                            }else{
                                layer.msg("注册失败，请联系管理员");
                            }
			        });
		        
		        }
    		};
    
			
			$scope.gotologin = function(){
				window.location.href = '<?php echo U('login');?>';
			}
		
		});
		
		
	
</script>

</html>